package com.example.onion.hxchat.room.dao;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.example.onion.hxchat.room.entity.Apply;
import com.example.onion.hxchat.room.entity.Info;

import java.util.List;

/**
 * 对话框的dao
 * @author:onion
 * @data: 2020/7/8
 */
@Dao
public interface InfoDao {
    @Insert
    void insertInfo(Info... info);

    @Delete
    void deleteInfo(Info info);

    @Update
    void updateInfo(Info info);

    @Query("SELECT * FROM Info WHERE ownerUserId = :id")
    /**
     * 查询Id 是id的所有对话框信息
     */
    LiveData<List<Info>> getAllInfoCur(String id);



    @Query("SELECT * FROM Info")
    /**
     * 所有
     */
    LiveData<List<Info>> getAllInfo();

    @Query("update Info set lastInfo = :lastinfo where userId = :userId and ownerUserId =:ownerId")
    /**
     * 只更新userId和ownUserId对话框的最后一句显示的话
     */
    void insertJustLatInfo(String lastinfo,String userId,String ownerId);




    @Query("SELECT * FROM Info WHERE userId = :userId AND ownerUserId = :ownerId")
    /**
     * 得到id1 与id 的一个对话框信息
     */
    Info getInfoCur(String userId,String ownerId);




}
